<?php

defined('SYSPATH') or die('Access error!');

class Model_Attachment extends Model
{

    public function create_attachment_url($id)
    {
        //获取某个附件的连接
        $detail = $this->get_row(array('id' => $id), 'file_realname,file_path,module');
        return  IMAGES_FILE_PATH.'/'. $detail['module'] . '/' . $detail['file_path'] . $detail['file_realname'];
    }

    public function delete_attachment($id)
    {
        //获取附件的地址和名称
        $file_path = $this->create_attachment_url($id);
        File::delete_file($file_path);
        $this->delete(array('id'=>$id));
    }

}